<template>
  <div class="plug-container" @mousemove.prevent>
    <div class="plug-wrapper">
      <milk-input placeholder="搜一下"
                  v-model="searchKey"
                  @click="searchArticleByKey"></milk-input>

      <section class="one-plug">
        <h2>分类</h2>
        <div class="p-10">
          <ul class="milk-ul">
            <li class="milk-li"
                v-for="(v,i) in category"
                :key="i"
                @click="searchArticleByCategory(v.name)">
              <i class="fas fa-angle-right mr-3" style="color:#84a1d2;"></i>
              <span class="milk-li-content">{{ v.name }}</span>
              <span class="milk-li-suffix">{{ v.articleCount }}</span>
            </li>
          </ul>
        </div>
      </section>

      <section class="one-plug">
        <h2>这里比较热闹</h2>
        <!--        <div class="plug-head f-y-center">-->
        <!--          <img class="wh30" src="/image/others/heart.svg" alt="">-->
        <!--          <span class="ml-5">这里比较热闹</span>-->
        <!--        </div>-->
        <div class="p-10">
          <milk-article-simple v-for="article in hotArticle"
                               :value="article"
                               :key="article._id"
          ></milk-article-simple>
        </div>
      </section>

      <section class="one-plug">
        <h2>标签云</h2>
        <!--        <div class="plug-head f-y-center">-->
        <!--          <img class="wh30" src="/image/others/tag.svg" alt="">-->
        <!--          <span class="ml-5">标签云</span>-->
        <!--        </div>-->
        <div class="p-10">
          <milk-tag v-for="(v,i) in hotTag" :key="i" :tag="v"></milk-tag>
        </div>
      </section>

      <!--      <section class="one-plug">-->
      <!--        <div class="plug-head f-y-center">-->
      <!--          <img class="wh30" src="/image/others/tag.svg" alt="">-->
      <!--          <span class="ml-5">归档</span>-->
      <!--        </div>-->
      <!--      </section>-->

    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  name: 'plugs',
  data: () => ({
    searchKey: ''
  }),
  computed: {
    ...mapState('daisy/blog', [
      'category', 'hotTag', 'hotArticle'
    ]),
  },
  methods: {
    searchArticleByKey () {
      this.$router.push({
        path: '/article/search', query: {
          key: this.searchKey
        }
      })
    },
    searchArticleByCategory (e) {
      this.$router.push({
        path: '/article/search', query: {
          category: e
        }
      })
    }
  },
}
</script>

<style>
.plug-container {
  position: relative;
  /*min-height: 100%;*/
  padding: 48px 38px;
  /*background-color: #f8f9fa;*/
}

.plug-container h3 {
  color: #6a6a6a;
}

.plug-wrapper {
  width: 100%;
  margin: 0 auto;
}

/*列表 START*/
.milk-li {
  position: relative;
  cursor: pointer;
  font-size: 15px;
  line-height: 26px;
  font-weight: 300;
  color: #535353;
  padding-bottom: 5px;
  margin-bottom: 10px;
  letter-spacing: .5px;
  border-bottom: 1px solid #d8d8d8;
  transition: 0.2s ease-in-out;
}

.milk-li-suffix {
  position: absolute;
  width: 40px;
  text-align: center;
  border-radius: 4px;
  right: 0;
  top: 0;
}

.milk-li:hover .milk-li-suffix {
  background-color: #a175ed;
  color: #FFFFFF;
}

.milk-li:hover .milk-li-content {
  color: #a175ed;
}

/*列表 END*/

.one-plug {
  position: relative;
  margin-top: 24px;
  padding: 8px;
  /*BFC*/
  overflow: hidden;
  border-radius: 16px;
  /*background-color: #f2f7fc;*/
  background-color: #FFFFFF;
  box-shadow: 0 0 2rem 0 rgba(136, 152, 170, .15);
  letter-spacing: 0.3px;
}

.one-plug > h2 {
  position: relative;
  margin-top: 10px;
  margin-bottom: 0;
  margin-left: 20px;
  color: #7d7d7d;
}


.plug-head {
  font-size: 12px;
  font-weight: 600;
  color: #697982;
  padding-left: 14px;
}

.plug-head > img {
  /*width: 40px;*/
  /*height: 40px;*/
}

/*.one-plug > h2::before {*/
/*  content: '';*/
/*  position: absolute;*/
/*  width: 34px;*/
/*  height: 3px;*/
/*  background-color: #54b3ea;*/
/*  left: 0;*/
/*  bottom: -14px;*/
/*}*/


/*1200px 以上 plug-container 在右边*/
@media (min-width: 1200px) {
  .plug-container {
    flex: 0 0 380px;
    padding-left: 0;
  }
}

@media (max-width: 992px) {
  .plug-container {
    padding: 14px 24px !important;
  }
}
</style>
